<style lang="scss" scoped>
  @import '../../styles/common/loading.less';
  .container{
    border: none !important;
    margin-top: 4px;
  }
  .el-col-offset-1 {
    margin-left: 0%;
  }
  .button_a {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);

  }
  .col_a {
    margin-left: 2%;
  }
  .el-card {
    height: 200px;
  }

  .el-button--primary {
    background-color: rgba(255, 138, 0, 1);
    border-color: rgba(255, 138, 0, 1);
  }
</style>
<template>
    <div>
        <div class="container">
            <div>
              <el-form :model="formInline"  class="select-submit-form">
                  <el-row type="flex">
                    <el-col :span="8">
                      <el-form-item label="医疗机构编码">
                        <el-input v-model="formInline.hospCode"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="医疗机构名称">
                        <el-input v-model="formInline.hospName"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8" >
                      <el-form-item label="医院等级">
                        <el-select  v-model="formInline.hospLevel">
                          <el-option
                            v-for="item in HospLevel"
                            :key="item.codeCode"
                            :label="item.codeCName"
                            :value="item.codeCode">
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row>
                    <el-col :span="24">
                      <div class="select-btn-group">
                        <el-button type="primary" size="medium"  @click="onSubmitYljixxgl">查询</el-button>
                        <el-button type="primary" size="medium" @click="handleReset">重置</el-button>
                        <el-button type="primary" size="medium" @click="save()" >增加</el-button>
                      </div>
                    </el-col>
                  </el-row>
              </el-form>
              <el-table
                  :data="tableData"

                  class="table"
                  ref="multipleTable"
                  header-cell-class-name="table-header"
                  style="margin: 30px 0;border: 1px solid #d6d9d8;"
                  v-loading="loading"
                  element-loading-text="Loading....."
              >
                  <el-table-column type="index" width="55" align="center"></el-table-column>
                  <el-table-column prop="hospCode" label="医疗机构编码" align="center"></el-table-column>
                  <el-table-column prop="hospName" label="医疗机构名称" align="center"></el-table-column>
                  <el-table-column prop="hospLevel" :formatter="hospLevelFormat" label="医院等级" align="center"></el-table-column>
                <el-table-column prop="linkerMobile" label="联系电话" align="center"></el-table-column>
                  <el-table-column prop="PZRQ" label="批准日期" align="center"></el-table-column>
                  <el-table-column prop="endDate" label="截止日期" align="center"></el-table-column>
                <el-table-column prop="delFlag"   :formatter="delFlagFormat" label="有效标志" align="center"></el-table-column>
                  <el-table-column label="操作" width="180" align="center">
                    <template slot-scope="scope">
                      <el-button
                        size="mini"
                        type="text"
                        @click="handleLook(scope.$index, scope.row)">查看</el-button>
                      <el-button
                        size="mini"
                        type="text"
                        @click="handleEdit(scope.$index, scope.row)">修改</el-button>
                      <el-button
                        size="mini"
                        type="text"
                        @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                    </template>
                  </el-table-column>
              </el-table>
              <div class="pagination" v-if="this.tableData.length!==0">
                <div class="index_page">
                  <el-pagination :current-page="pagination.currentPage" :page-size="pagination.rowsNumber"
                                 :page-sizes="[10, 20, 50, 100]"
                                 :total="pagination.totalPage" background layout="prev, pager, next,sizes,total,jumper"
                                 @size-change="handleSizeChange" @current-change="queryFun">
                  </el-pagination>
                </div>
              </div>
            </div>
        </div>
    </div>
</template>

<script>
import * as api1 from '@/api/baseDate'
import * as api from '@/api/basicInformation'
export default {
    name: 'baseform',
    data() {
        return {
          loading: false,
          pagination: {
            currentPage: 1, // 当前页
            rowsNumber: 10, // 每页条数
            totalPage: 0 // 总条数
          },
          item:0,
          checkList: ['急诊'],
          props: { multiple: true },
          dialogFormVisible: false,
          tableData: [],
          requestDTO:{},
          formInline:{},
          medicalInstitutionMessageDemo:{},
          HospLevel:[],
        };
    },
  created() {
    this.HospLevel1()
    this.onSubmitYljixxgl();
  },
    methods: {
      delFlagFormat(row, column) {
        let delFlag = row.delFlag
        if (delFlag === 0) {
          return '无效'
        } else if (delFlag === 1) {
          return '有效'
        }
      },
      hospLevelFormat(row, column) {
        let hospLevel = row.hospLevel
        if (hospLevel === '0') {
          return '一级甲等医院'
        } else if (hospLevel === '1') {
          return '一级乙等医院'
        }else if (hospLevel === '2') {
          return '一级丙等医院'
        } else if (hospLevel === '3') {
          return '二级甲等医院'
        }else if (hospLevel === '4') {
          return '二级乙等医院'
        } else if (hospLevel === '5') {
          return '二级丙等医院'
        }else if (hospLevel === '6') {
          return '三级甲等医院'
        } else if (hospLevel === '7') {
          return '三级乙等医院'
        }else if (hospLevel === '8') {
          return '三级丙等医院'
        } else if (hospLevel === '9') {
          return '三级特等医院'
        }else if (hospLevel === '10') {
          return '其他'
        }
      },
      handleSizeChange(pageSize){ // 改变当前页条数事件
        this.pagination.rowsNumber=pageSize
        this.onSubmitYljixxgl();
        /* let pageIndex = this.pagination.currentPage;
         this.querySettleAuditTaskList(pageIndex,pageSize);*/
      },
      queryFun(pageNum){ // 改变当前页事件
        this.pagination.currentPage=pageNum
        this.onSubmitYljixxgl();
        /* let rowsNumber = this.pagination.rowsNumber;
         this.querySettleAuditTaskList(pageNum,rowsNumber);*/
      },
      // 添加
      save(){
        this.$router.push({
          name: 'medicalInstitutionMessageDemo',
          query: {
            medicalInstitutionMessageDemo: JSON.stringify(this.medicalInstitutionMessageDemo),
            item: JSON.stringify(0),
          }
        })
      },
      // 查询
      onSubmitYljixxgl(){
        var data={
          "hospCode":this.formInline.hospCode,
          "hospName":this.formInline.hospName,
          "hospLevel":this.formInline.hospLevel,
          "pageNum":this.pagination.currentPage,
          "pageSize":this.pagination.rowsNumber,
        }
        api.getQueryHospCompany(data
        ).then(res => {
          if(res){
            if(res.data.resultCode !== '0000'){
              this.$message.error(res.data.resultMsg);
            }else{
                this.tableData = res.data.list;
                this.pagination.totalPage=res.data.total;
            }
          }else{
              this.$message.error('系统异常');
          }
        })
      },
      // 重置
      handleReset(){

      },
      // 查看
      handleLook(index,row){
        this.medicalInstitutionMessageDemo=row,
        this.$router.push({
          name: 'medicalInstitutionMessageDemo',
          query: {
            medicalInstitutionMessageDemo: JSON.stringify(this.medicalInstitutionMessageDemo),
            item: JSON.stringify(2),
          }
        })
      },
      // 修改
      handleEdit(index,rew){
        this.medicalInstitutionMessageDemo=rew,
          this.$router.push({
            name: 'medicalInstitutionMessageDemo',
            query: {
              medicalInstitutionMessageDemo: JSON.stringify(this.medicalInstitutionMessageDemo),
              item: JSON.stringify(1),
            }
          })
      },
      // 删除
      handleDelete(index,rew){
          var data={
            "id":rew.id,
          }
          api.getDeleteHospCompany(data
          ).then(res => {
            if(res.data.resultCode){
              if(res.data.resultCode !== '0000'){
                this.$message.error(res.data.resultMsg);
              }else{
                this.$message.success(res.data.resultMsg);
              }
            }
            this.reload();
          })
      },
      // 医院等级
      HospLevel1(){
        var data={
          "codeType": "HospLevel"
        }
        api1.MedType(data
        ).then(res => {
          // debugger
          this.HospLevel=res.data
        })
      },
        onSubmit() {
            this.$message.success('提交成功！');
        },
        // 分页导航
        handlePageChange(val) {
            this.$set(this.query, 'pageIndex', val);
            this.getData();
        },
    }
};
</script>